/**
 * 
 */
package hk.edu.cityu.is.riskmgmt.data;

import java.util.Arrays;

/**
 * @author chaolu
 * 
 */
public class SharedData {
	private int bankno = 3;
	private int tick = 0;
	private double shockrate = 0;
	private int shockfreq = 0;
	private int lossfreq = 0;
	private double lossrate = 0;
	private int simutype = 0;
	private double outflows = 1;

	/**
	 * @return the outflows
	 */
	public double getOutflows() {
		return outflows;
	}

	/**
	 * @param outflows
	 *            the outflows to set
	 */
	public void setOutflows(double outflows) {
		this.outflows = outflows;
	}

	/**
	 * @return the rsf
	 */
	public double getRsf() {
		return rsf;
	}

	/**
	 * @param rsf
	 *            the rsf to set
	 */
	public void setRsf(double rsf) {
		this.rsf = rsf;
	}

	private double rsf = 1;

	/**
	 * @return the shockfreq
	 */
	public int getShockfreq() {
		return shockfreq;
	}

	/**
	 * @param shockfreq
	 *            the shockfreq to set
	 */
	public void setShockfreq(int shockfreq) {
		this.shockfreq = shockfreq;
	}

	public int getSimutype() {
		return simutype;
	}

	/**
	 * @param shockfreq
	 *            the shockfreq to set
	 */
	public void setSimutype(int simutype) {
		this.simutype = simutype;
	}

	/**
	 * @return the shockfreq
	 */
	public int getLossfreq() {
		return lossfreq;
	}

	/**
	 * @param shockfreq
	 *            the shockfreq to set
	 */
	public void setLossfreq(int lossfreq) {
		this.lossfreq = lossfreq;
	}

	/**
	 * @return the shockrate
	 */
	public double getShockrate() {
		return shockrate;
	}

	/**
	 * @param shockrate
	 *            the shockrate to set
	 */
	public void setShockrate(double shockrate) {
		this.shockrate = shockrate;
	}

	/**
	 * @return the shockrate
	 */
	public double getLossrate() {
		return lossrate;
	}

	/**
	 * @param shockrate
	 *            the shockrate to set
	 */
	public void setLossrate(double lossrate) {
		this.lossrate = lossrate;
	}

	private double[] bank_cash = new double[bankno];
	private double[] stock_price_last = new double[8];
	private double[] fx_price_last = new double[8];
	private double[] usd_ir_last = new double[161];
	private double[][] usd_ir = new double[10][161];
	private double[][] fx = new double[8][161];
	private double[][] interbank_payment = new double[bankno][bankno];
	private boolean[] isDefault = new boolean[bankno];
	private double[][] stockprice = new double[6][161];
	private double[] cds = new double[10000];
	private double[] trading_assets = new double[bankno];
	private double[] capital_reserve = new double[bankno];
	private double[] payment_vector = new double[bankno];
	private double[][] total_capital = new double[bankno][161];
	private double[] total_capital_in_last = new double[bankno];
	private double[] total_capital_out_last = new double[bankno];
	private double[] totalfx = new double[bankno];
	private double[] total_asset = new double[161];

	/**
	 * @return the total_asset
	 */
	public double[] getTotal_asset() {
		return total_asset;
	}
	public double getOneTotal_asset(int n) {
		return total_asset[n];
	}

	/**
	 * @param total_asset
	 *            the total_asset to set
	 */
	public void setTotal_asset(double[] total_asset) {
		this.total_asset = total_asset;
	}

	public void setOneTotal_asset(int n, double value) {
		this.total_asset[n] = value;
	}

	/**
	 * @return the pledged_asset
	 */
	public double[] getPledged_asset() {
		return pledged_asset;
	}

	public double getOnePledged_asset(int n) {
		return pledged_asset[n];
	}

	/**
	 * @param pledged_asset
	 *            the pledged_asset to set
	 */
	public void setPledged_asset(double[] pledged_asset) {
		this.pledged_asset = pledged_asset;
	}

	public void setOnePledged_asset(int n, double value) {
		this.pledged_asset[n] = value;
	}

	private double[] pledged_asset = new double[161];

	/**
	 * @return the netpayment
	 */
	public double[] getNetpayment() {
		return netpayment;
	}

	public double getOneNetPayment(int no) {
		return this.netpayment[no];
	}

	/**
	 * @param netpayment
	 *            the netpayment to set
	 */
	public void setNetpayment(double[] netpayment) {
		this.netpayment = netpayment;
	}

	public void setOneNetPayment(int no, double num) {
		this.netpayment[no] = num;
	}

	private double[] netpayment = new double[bankno];

	/**
	 * @return the totalfx
	 */
	public double[] getTotalfx() {
		return totalfx;
	}

	public double getOneTotalfx(int no) {
		return totalfx[no];
	}

	/**
	 * @param totalfx
	 *            the totalfx to set
	 */
	public void setTotalfx(double[] totalfx) {
		this.totalfx = totalfx;
	}

	public void setOneTotalfx(int no, double fx) {
		this.totalfx[no] = fx;
	}

	/**
	 * @return the totalir
	 */
	public double[] getTotalir() {
		return totalir;
	}

	public double getOneTotalir(int no) {
		return totalir[no];
	}

	/**
	 * @param totalir
	 *            the totalir to set
	 */
	public void setTotalir(double[] totalir) {
		this.totalir = totalir;
	}

	public void setOneTotalir(int no, double ir) {
		this.totalir[no] = ir;
	}

	private double[] totalir = new double[bankno];

	public int getTick() {

		return tick;
	}

	public void setTick(int tick) {
		this.tick = tick;
	}

	public double[] getTotal_capital_in_last() {
		return total_capital_in_last;
	}

	public double[][] getTotal_capital() {
		return total_capital;
	}

	public double[] getOneBankTotal_capital(int no) {
		return total_capital[no];
	}

	public void setTotal_capital(double[][] total_capital) {
		this.total_capital = total_capital;
	}

	public double getOneTotal_capital_in_last(int no) {
		return total_capital_in_last[no];
	}

	public void setTotal_capital_in_last(double[] total_capital_in_last) {
		this.total_capital_in_last = total_capital_in_last;
	}

	public void setOneTotal_capital_price_in_last(int no, double value) {
		this.total_capital_in_last[no] = value;
	}

	public double getOneTotal_capital_out_last(int no) {
		return total_capital_out_last[no];
	}

	public void setTotal_capital_out_last(double[] total_capital_out_last) {
		this.total_capital_out_last = total_capital_out_last;
	}

	public void setOneTotal_capital_price_out_last(int no, double value) {
		this.total_capital_out_last[no] = value;
	}

	public double[] getStock_price_last() {
		return stock_price_last;
	}

	public double getOneStock_price_last(int no) {
		return stock_price_last[no];
	}

	public void setStock_price_last(double[] stock_price_last) {
		this.stock_price_last = stock_price_last;
	}

	public void setOneStock_price_last(int no, double value) {
		this.stock_price_last[no] = value;
	}

	public double[] getFx_price_last() {
		return fx_price_last;
	}

	public double getOneFx_price_last(int no) {
		return fx_price_last[no];
	}

	public void setFx_price_last(double[] fx_price_last) {
		this.fx_price_last = fx_price_last;
	}

	public void setOneFx_price_last(int no, double value) {
		this.fx_price_last[no] = value;
	}

	public double[] getUsd_ir_last() {
		return usd_ir_last;
	}

	public double getOneUsd_ir_last(int no) {
		return usd_ir_last[no];
	}

	public void setUsd_ir_last(double[] usd_ir_last) {
		this.usd_ir_last = usd_ir_last;
	}

	public void setOneUsd_ir_last(int no, double value) {
		this.usd_ir_last[no] = value;
	}

	public double[][] getUsd_ir() {
		return usd_ir;
	}

	public void setUsd_ir(double[][] usd_ir) {
		this.usd_ir = usd_ir;
	}

	public double[][] getFx() {
		return fx;
	}

	public void setFx(double[][] fx) {
		this.fx = fx;
	}

	public double[][] getStockprice() {
		return stockprice;
	}

	public void setStockprice(double[][] stockprice) {
		this.stockprice = stockprice;
	}

	public double[] getCds() {
		return cds;
	}

	public double getOneCds(int no) {
		return cds[no];
	}

	public void setCds(int no, double value) {
		this.cds[no] = value;
	}

	public double[] getPayment_vector() {
		return payment_vector;
	}

	public void setPayment_vector(double[] payment_vector) {
		this.payment_vector = payment_vector;
	}

	public double[] getCapital_reserve() {
		return capital_reserve;
	}

	public void setCapital_reserve(double[] capital_reserve) {
		this.capital_reserve = capital_reserve;
	}

	public double[][] getInterbank_payment() {
		return interbank_payment;
	}

	public void setInterbank_payment(double[][] interbank_payment) {
		this.interbank_payment = interbank_payment;
	}

	public boolean[] getIsDefault() {
		return isDefault;
	}

	public void setIsDefault(boolean[] isDefault) {
		this.isDefault = isDefault;
	}

	public int getBankno() {
		return bankno;
	}

	public void setBankno(int bankno) {
		this.bankno = bankno;
	}

	public double[] getBank_cash() {
		return bank_cash;
	}

	public void setBank_cash(double[] bank_cash) {
		this.bank_cash = bank_cash;
	}

	public double[] getTrading_assets() {
		return trading_assets;
	}

	public void setTrading_assets(double[] trading_assets) {
		this.trading_assets = trading_assets;
	}

	public void setOneBankCash(int no, double cash) {
		double[] temp = new double[getBankno()];
		temp = getBank_cash();
		temp[no] = cash;
		setBank_cash(temp);
	}

	public double getOneBankCash(int no) {
		double[] temp = new double[getBankno()];
		temp = getBank_cash();
		return temp[no];
	}

	public double getOneBankTradingAssets(int no) {
		double[] temp = getTrading_assets();
		return temp[no];
	}

	public void setOneBankTradingAssets(int no, double cash) {
		double[] temp = getTrading_assets();
		temp[no] = cash;
		setTrading_assets(temp);
	}

	public double getOneBankCapitalReserve(int no) {
		double[] temp = this.getCapital_reserve();
		return temp[no];
	}

	public void setOneBankCapitalReserve(int no, double cash) {
		double[] temp = this.getCapital_reserve();
		temp[no] = cash;
		this.setCapital_reserve(temp);
	}

	public boolean getOneBankIsDefault(int no) {
		return getIsDefault()[no];
	}

	public void setOneBankIsDefault(int no, boolean b) {
		boolean[] temp = getIsDefault();
		temp[no] = b;
		this.setIsDefault(temp);
	}

	public double getOneBankPaymentVector(int no) {
		return this.getPayment_vector()[no];
	}

	public void setOneBankPaymentVector(int no, double cash) {
		double[] temp = this.getPayment_vector();
		temp[no] = cash;
		this.setPayment_vector(temp);
	}

	public double getOneBankTotalAssets(int no) {
		return this.getAssets()[no];
	}

	public void setOneBankTotalAssets(int no, double cash) {
		double[] temp = this.getAssets();
		temp[no] = cash;
		this.setAssets(temp);
	}

	private double[] total_assets = new double[bankno];

	public double[] getAssets() {
		return total_assets;
	}

	public void setAssets(double[] total_assets) {
		this.total_assets = total_assets;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("SharedData [bankno=");
		builder.append(bankno);
		builder.append(", tick=");
		builder.append(tick);
		builder.append(", bank_cash=");
		builder.append(Arrays.toString(bank_cash));
		builder.append(", stock_price_last=");
		builder.append(Arrays.toString(stock_price_last));
		builder.append(", fx_price_last=");
		builder.append(Arrays.toString(fx_price_last));
		builder.append(", usd_ir_last=");
		builder.append(Arrays.toString(usd_ir_last));
		builder.append(", usd_ir=");
		builder.append(Arrays.toString(usd_ir));
		builder.append(", fx=");
		builder.append(Arrays.toString(fx));
		builder.append(", interbank_payment=");
		builder.append(Arrays.toString(interbank_payment));
		builder.append(", isDefault=");
		builder.append(Arrays.toString(isDefault));
		builder.append(", stockprice=");
		builder.append(Arrays.toString(stockprice));
		builder.append(", cds=");
		builder.append(Arrays.toString(cds));
		builder.append(", trading_assets=");
		builder.append(Arrays.toString(trading_assets));
		builder.append(", capital_reserve=");
		builder.append(Arrays.toString(capital_reserve));
		builder.append(", payment_vector=");
		builder.append(Arrays.toString(payment_vector));
		builder.append("]");
		return builder.toString();
	}

}
